﻿<UserControl x:Class="OSTWin.ucConfiguration"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition />
        </Grid.RowDefinitions>
        <ScrollViewer Grid.Row="0" VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Disabled" Margin="0,0,0,0">
            <StackPanel>
                <TextBlock Name="Name" Text="{Binding Path=Config.Name, StringFormat=Instanzname: {0}, FallbackValue=no-config-loaded}" FontWeight="Medium"></TextBlock>
                <TextBlock Name="Version" Text="{Binding Path=Config.Vers, StringFormat=Configuration-XML-Version: {0}, FallbackValue=no-config-loaded}" FontWeight="Medium"></TextBlock>

                <Expander Header="Logging" IsExpanded="True">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition />
                            <ColumnDefinition Width="80" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                        </Grid.RowDefinitions>
                        <!--<TextBlock FontWeight="Medium" Grid.Row="0" Grid.Column="0">Level (Debug=0,Info=1,Warning=2,Error=3):</TextBlock>-->
                        <TextBlock Grid.Row="0" Grid.Column="0">Level:</TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="0">ToDebug:</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="0">ToFile:</TextBlock>
                        <TextBlock Grid.Row="3" Grid.Column="0">ToRss:</TextBlock>
                        <TextBlock Grid.Row="4" Grid.Column="0">Size:</TextBlock>

                        <ComboBox Name="cmbLevel" Tag="logging?Level={0}" Grid.Row="0" Grid.Column="1" SelectedIndex="{Binding Path=Config.Logging.Level}" >
                            <ComboBoxItem Tag="0" Content="Debug"></ComboBoxItem>
                            <ComboBoxItem Tag="1" Content="Info"></ComboBoxItem>
                            <ComboBoxItem Tag="2" Content="Warning"></ComboBoxItem>
                            <ComboBoxItem Tag="3" Content="Error"></ComboBoxItem>
                        </ComboBox>
                        <CheckBox Name="chkToDebug" Tag="logging?ToDebug={0}" Grid.Row="1" Grid.Column="1" IsChecked="{Binding Path=Config.Logging.ToDebug}" />
                        <CheckBox Name="chkToFile" Tag="logging?ToFile={0}" Grid.Row="2" Grid.Column="1" IsChecked="{Binding Path=Config.Logging.ToFile}"  />
                        <CheckBox Name="chkToRss" Tag="logging?ToRss={0}" Grid.Row="3" Grid.Column="1" IsChecked="{Binding Path=Config.Logging.ToRss}"  />
                        <TextBox Name="txtSize" Tag="logging?Size={0}" Grid.Row="4" Grid.Column="1" Text="{Binding Path=Config.Logging.Size}"></TextBox>

                        <Button Name="btnLevel" Tag="cmbLevel" Grid.Row="0" Grid.Column="2" Click="cmb_SelectionChanged" Content="Apply" />
                        <Button Name="btnToDebug" Tag="chkToDebug" Grid.Row="1" Grid.Column="2" Click="chk_Changed" Content="Apply" />
                        <Button Name="btnToFile" Tag="chkToFile" Grid.Row="2" Grid.Column="2" Click="chk_Changed" Content="Apply" />
                        <Button Name="btnToRss" Tag="chkToRss" Grid.Row="3" Grid.Column="2" Click="chk_Changed" Content="Apply" />
                        <Button Name="btnSize" Tag="txtSize" Grid.Row="4" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                    </Grid>


                </Expander>
                <Expander Header="Location" IsExpanded="True">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition />
                            <ColumnDefinition Width="80" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0">Longitude:</TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="0">Latitude:</TextBlock>

                        <TextBox Name="txtLong" Tag="location?Long={0}" Grid.Row="0" Grid.Column="1" Text="{Binding Path=Config.Location.Long}"></TextBox>
                        <TextBox Name="txtLat" Tag="location?Lat={0}" Grid.Row="1" Grid.Column="1" Text="{Binding Path=Config.Location.Lat}"></TextBox>

                        <Button Name="btnLong" Tag="txtLong" Grid.Row="0" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnLat" Tag="txtLong"  Grid.Row="1" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                    </Grid>

                </Expander>
                <Expander Header="TimeService" IsExpanded="True">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition />
                            <ColumnDefinition Width="80" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0">UseNtp:</TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="0">NtpServer:</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="0">TimeZone:</TextBlock>
                        <TextBlock Grid.Row="3" Grid.Column="0">DateTime:</TextBlock>

                        <CheckBox Name="chkUseNtp" Tag="timeservice?UseNtp={0}" Grid.Row="0" Grid.Column="1" IsChecked="{Binding Path=Config.TimeService.UseNtp}" />
                        <TextBox Name="txtNtpServer" Tag="timeservice?NtpServer={0}" Grid.Row="1" Grid.Column="1" Text="{Binding Path=Config.TimeService.NtpServer}"></TextBox>
                        <TextBox Name="txtTimeZone" Tag="timeservice?TimeZone={0}" Grid.Row="2" Grid.Column="1" Text="{Binding Path=Config.TimeService.TimeZone}"></TextBox>
                        <TextBox Name="txtDateTime" Tag="timeservice?Value={0}" Grid.Row="3" Grid.Column="1" Text="{Binding Path=Config.TimeService.Value}"></TextBox>

                        <Button Name="btnUseNtp" Tag="chkUseNtp" Grid.Row="0" Grid.Column="2" Click="chk_Changed" Content="Apply" />
                        <Button Name="btnNtpServer" Tag="txtNtpServer" Grid.Row="1" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnTimeZone" Tag="txtTimeZone" Grid.Row="2" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnDateTime" Tag="txtDateTime" Grid.Row="3" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                    </Grid>

                </Expander>
                <Expander Header="Frame" IsExpanded="True">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition />
                            <ColumnDefinition Width="80" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0">Offset:</TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="0">MotorAlign:</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="0">Body:</TextBlock>
                        <TextBlock Grid.Row="3" Grid.Column="0">Stroke:</TextBlock>
                        <TextBlock Grid.Row="4" Grid.Column="0">Leg:</TextBlock>
                        <TextBlock Grid.Row="5" Grid.Column="0">Arm:</TextBlock>
                        <TextBlock Grid.Row="6" Grid.Column="0">WindAlarm:</TextBlock>

                        <TextBox Name="txtOffset" Tag="frame?Offset={0}" Grid.Row="0" Grid.Column="1" Text="{Binding Path=Config.Frame.Offset}"></TextBox>
                        <ComboBox Name="cmbMotorAlign" Tag="frame?MotorAlign={0}" Grid.Row="1" Grid.Column="1" SelectedIndex="{Binding Path=Config.Frame.MotorAlign}">
                            <ComboBoxItem Tag="0" Content="None"></ComboBoxItem>
                            <ComboBoxItem Tag="1" Content="East"></ComboBoxItem>
                            <ComboBoxItem Tag="2" Content="West"></ComboBoxItem>
                        </ComboBox>
                        <TextBox Name="txtBody" Tag="frame?Body={0}" Grid.Row="2" Grid.Column="1" Text="{Binding Path=Config.Frame.Body}"></TextBox>
                        <TextBox Name="txtStroke" Tag="frame?Stroke={0}" Grid.Row="3" Grid.Column="1" Text="{Binding Path=Config.Frame.Stroke}"></TextBox>
                        <TextBox Name="txtLeg" Tag="frame?Leg={0}" Grid.Row="4" Grid.Column="1" Text="{Binding Path=Config.Frame.Leg}"></TextBox>
                        <TextBox Name="txtArm" Tag="frame?Arm={0}" Grid.Row="5" Grid.Column="1" Text="{Binding Path=Config.Frame.Arm}"></TextBox>
                        <TextBox Name="txtWindAlarm" Tag="frame?WindAlarm={0}" Grid.Row="6" Grid.Column="1" Text="{Binding Path=Config.Frame.WindAlarm}"></TextBox>

                        <Button Name="btnOffset" Tag="txtOffset" Grid.Row="0" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnMotorAlign" Tag="cmbMotorAlign" Grid.Row="1" Grid.Column="2" Click="cmb_SelectionChanged" Content="Apply" />
                        <Button Name="btnBody" Tag="txtBody" Grid.Row="2" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnStroke" Tag="txtStroke" Grid.Row="3" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnLeg" Tag="txtLeg" Grid.Row="4" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnArm" Tag="txtArm" Grid.Row="5" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnWindAlarm" Tag="txtWindAlarm" Grid.Row="6" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                    </Grid>
                </Expander>
                <Expander Header="Motor" IsExpanded="True">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition />
                            <ColumnDefinition Width="80" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0">Class:</TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="0">SensorDelay:</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="0">InitWait:</TextBlock>
                        <TextBlock Grid.Row="3" Grid.Column="0">MoveDuration:</TextBlock>
                        <TextBlock Grid.Row="4" Grid.Column="0">Preload:</TextBlock>
                        <TextBlock Grid.Row="5" Grid.Column="0">OverrunThreshold:</TextBlock>
                        <TextBlock Grid.Row="6" Grid.Column="0">Overrun:</TextBlock>

                        <TextBox Name="txtClass" Tag="motor?Class={0}" Grid.Row="0" Grid.Column="1" Text="{Binding Path=Config.Motor.Class}"></TextBox>
                        <TextBox Name="txtSensorDelay" Tag="motor?Delay={0}" Grid.Row="1" Grid.Column="1" Text="{Binding Path=Config.Motor.Delay}"></TextBox>
                        <TextBox Name="txtInitWait" Tag="motor?Wait={0}" Grid.Row="2" Grid.Column="1" Text="{Binding Path=Config.Motor.Wait}"></TextBox>
                        <TextBox Name="txtMoveDuration" Tag="motor?Duration={0}" Grid.Row="3" Grid.Column="1" Text="{Binding Path=Config.Motor.Duration}"></TextBox>
                        <TextBox Name="txtPreload" Tag="motor?Preload={0}" Grid.Row="4" Grid.Column="1" Text="{Binding Path=Config.Motor.Preload}"></TextBox>
                        <TextBox Name="txtOverrunThreshold" Tag="motor?OverrunThr={0}" Grid.Row="5" Grid.Column="1" Text="{Binding Path=Config.Motor.OverrunThr}"></TextBox>
                        <TextBox Name="txtOverrun" Tag="motor?Overrun={0}" Grid.Row="6" Grid.Column="1" Text="{Binding Path=Config.Motor.Overrun}"></TextBox>

                        <Button Name="btnClass" Tag="txtClass" Grid.Row="0" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnSensorDelay" Tag="txtSensorDelay" Grid.Row="1" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnInitWait" Tag="txtInitWait" Grid.Row="2" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnMoveDuration" Tag="txtMoveDuration" Grid.Row="3" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnPreload" Tag="txtPreload" Grid.Row="4" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnOverrunThreshold" Tag="txtOverrunThreshold" Grid.Row="5" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnOverrun" Tag="txtOverrun" Grid.Row="6" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                    </Grid>
                </Expander>
                <Expander Header="Ethernet" IsExpanded="True">
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="150"/>
                            <ColumnDefinition />
                            <ColumnDefinition Width="80" />
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                            <RowDefinition Height="28" />
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="0" Grid.Column="0">UseStatic:</TextBlock>
                        <TextBlock Grid.Row="1" Grid.Column="0">IP:</TextBlock>
                        <TextBlock Grid.Row="2" Grid.Column="0">Subnet-Mask:</TextBlock>
                        <TextBlock Grid.Row="3" Grid.Column="0">Dns:</TextBlock>
                        <TextBlock Grid.Row="5" Grid.Column="0">Gateway:</TextBlock>

                        <CheckBox Name="chkUseStatic" Tag="ethernet?UseStatic={0}" Grid.Row="0" Grid.Column="1" IsChecked="{Binding Path=Config.Ethernet.UseStatic}" />
                        <TextBox Name="txtIP" Tag="ethernet?IP={0}"  Grid.Row="1" Grid.Column="1" Text="{Binding Path=Config.Ethernet.IP}"></TextBox>
                        <TextBox Name="txtSubnet" Tag="ethernet?Mask={0}" Grid.Row="2" Grid.Column="1" Text="{Binding Path=Config.Ethernet.Mask}"></TextBox>
                        <TextBox Name="txtDns" Tag="ethernet?Dns={0}"  Grid.Row="3" Grid.Column="1" Text="{Binding Path=Config.Ethernet.Dns}"></TextBox>
                        <TextBox Name="txtGateway" Tag="ethernet?Gateway={0}" Grid.Row="4" Grid.Column="1" Text="{Binding Path=Config.Ethernet.Gateway}"></TextBox>

                        <Button Name="btnUseStatic" Tag="chkUseStatic" Grid.Row="0" Grid.Column="2" Click="chk_Changed" Content="Apply" />
                        <Button Name="btnIP" Tag="txtIP" Grid.Row="1" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnSubnet" Tag="txtSubnet" Grid.Row="2" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnDns" Tag="txtDns" Grid.Row="3" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                        <Button Name="btnGateway" Tag="txtGateway" Grid.Row="4" Grid.Column="2" Click="btnChangeConfig_Click" Content="Apply" />
                    </Grid>

                </Expander>
            </StackPanel>
        </ScrollViewer>
    </Grid>
</UserControl>
